package com.winning.sx.microframework.common.config;


import com.winning.dapi.data.sqlserver.SqlserverDataAccessService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
public class DataSourceConfig {

    @Bean(name = "primaryBootDataSource")
    @ConfigurationProperties(prefix="spring.datasource.sys")
    public DataSource primaryDataSource() {
        return DataSourceBuilder.create().build();
    }



    @Bean(name = "dataSource")
    public SqlserverDataAccessService primaryJdbcTemplate(
            @Qualifier("primaryBootDataSource") DataSource dataSource) {
        return new SqlserverDataAccessService("dataSource",dataSource);
    }


}